<template>
  <el-card style="margin: 10px" class="el-box">
    <el-form class="demo-form-inline">
      <el-form-item class="elfrom">
        一级分类:<el-select placeholder="一级分类" v-model="category1Id">
          <el-option
            v-for="list1 in Categorylist1"
            :key="list1.id"
            :label="list1.name"
            :value="list1.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item class="elfrom">
        二级分类:<el-select placeholder="二级分类" v-model="category2Id">
          <el-option
            v-for="list2 in Categorylist2"
            :key="list2.id"
            :label="list2.name"
            :value="list2.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item class="elfrom">
        三级分类:<el-select placeholder="三级分类" v-model="category3Id">
          <el-option
            v-for="list3 in Categorylist3"
            :key="list3.id"
            :label="list3.name"
            :value="list3.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script >
import { mapState, mapActions } from "vuex";

export default {
  name: "Seletor",
  computed: {
    category1Id: {
      get() {
        return this.Category1Id;
      },
      set(val) {
        console.log(val, "11");
        this.changeTwo(val);
      },
    },
    category2Id: {
      get() {
        return this.Category2Id;
      },
      set(val) {
        this.changeThree(val);
      },
    },
    category3Id: {
      get() {
        return this.Category3Id;
      },
      set(val) {
        this.setThree(val);
      },
    },
    ...mapState("opp", [
      "Categorylist1",
      "Categorylist2",
      "Categorylist3",
      "Category1Id",
      "Category2Id",
      "Category3Id",
    ]),
  },

  methods: {
    ...mapActions("opp", ["changeCount", "changeTwo", "changeThree","setThree"]),
  },
  mounted() {
    this.changeCount();
  },
};
</script>

<style scoped>
.demo-form-inline {
  display: flex;
}
.el-box .elfrom {
  margin-bottom: 0px;
  font-weight: bold;
  padding: 30px;
}
</style>